package com.study.mybatis.interceptor;

import org.apache.ibatis.executor.statement.StatementHandler;
import org.apache.ibatis.plugin.*;

import java.sql.Connection;
import java.util.Properties;

@Intercepts({@Signature(type = StatementHandler.class, method = "prepare", args = {Connection.class, Integer.class})})
public class MyInterceptor implements Interceptor {
    @Override
    public Object intercept(Invocation invocation) throws Throwable {
        System.out.println("intercept:");
        return invocation.proceed();
    }

    @Override
    public Object plugin(Object target) {
        System.out.println(target.getClass().getName());
        return target;/*Plugin.wrap(target, this);*/
    }

    @Override
    public void setProperties(Properties properties) {
        //System.out.println(properties.getProperty("name"));
        //System.out.println(properties.getProperty("age"));
    }
}